package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.annotation.OperLog;
import com.ytjj.qmyx.admin.constants.SysLogConstants;
import com.ytjj.qmyx.admin.model.request.OrderNoteRequest;
import com.ytjj.qmyx.admin.service.OrderNoteService;
import com.ytjj.qmyx.mall.model.OrderNote;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/orderNote")
public class OrderNoteController {

    @Autowired
    private OrderNoteService orderNoteService;

    @RequestMapping("/getOrderNoteList")
    @OperLog(operModule = "订单小记模块", operDesc = "订单小记列表", operType = SysLogConstants.OPERATION_SELECT)
    public CommonResult getOrderNoteList(@RequestBody OrderNoteRequest orderNoteRequest) {
        return CommonResult.success(orderNoteService.getOrderNoteList(orderNoteRequest));
    }

    @RequestMapping("/insertOrderNote")
    @OperLog(operModule = "订单小记模块", operDesc = "增加订单小记", operType = SysLogConstants.OPERATION_ADD)
    public CommonResult insertOrderNote(@RequestBody OrderNote orderNote) {
        int count = orderNoteService.insertOrderNote(orderNote);
        if (count > 0) {
            return CommonResult.success(count);
        } else {
            return CommonResult.failed();
        }
    }

    /**
     * 根据订单详情id查询客服备注
     */

    @GetMapping("/getOderServiceRemark")
    public CommonResult getOrderServiceRemark(@RequestParam("orderInfoId") Integer orderInfoId) {
        return CommonResult.success(orderNoteService.getOrderServiceRemark(orderInfoId));
    }
}
